package com.xiaoluo.lottery.vo;

import java.util.List;

/**
 * Created by Administrator on 2016/4/6.
 */
public class DataPage<T> {
    private List<T> content;
    private long total;
    private int pageIndex;
    private int pageSize;
    private int lastPage;

    public DataPage(List<T> content, long total, int pageIndex, int pageSize) {
        this.content = content;
        this.total = total;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.lastPage = 1;
        if (total % pageSize != 0) {
            this.lastPage = (int) (total / pageSize) + 1;
        } else {
            this.lastPage = (int) (total / pageSize);
        }
    }

    public DataPage() {

    }

    public List<T> getContent() {
        return content;
    }

    public void setContent(List<T> content) {
        this.content = content;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getContentSize() {
        return content.size();
    }

    public int getLastPage() {
        return lastPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("DataPage{");
        sb.append("content=").append(content);
        sb.append(", total=").append(total);
        sb.append(", pageIndex=").append(pageIndex);
        sb.append(", pageSize=").append(pageSize);
        sb.append('}');
        return sb.toString();
    }
}
